﻿namespace HuaWei
{
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraTreeList;
    using DevExpress.XtraTreeList.Columns;
    using HuaWei.CommClass;
    using HuaWei.DAI;
    using HuaWei.Windows.Forms;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    public class FrmCLQD : Form
    {
        [CompilerGenerated]
        private decimal _decimal;
        private string _str;
        private string _str1;
        public BindingSource bsCLQD;
        private SimpleButton btnAddQD;
        private SimpleButton btnAddQDChild;
        private SimpleButton btnClose;
        private SimpleButton btnDelQD;
        private SimpleButton btnSave;
        private TreeListColumn colBZ;
        private TreeListColumn colCLBH;
        private TreeListColumn colCLMC;
        private TreeListColumn colDFBL;
        private TreeListColumn colDJ;
        private TreeListColumn colDW;
        private TreeListColumn colJE;
        private TreeListColumn colSL;
        private DataSet dataSet = new DataSet();
        public bool hasData;
        private IContainer icontainer = null;
        private PanelControl panelControl5;
        private RepositoryItemComboBox repositoryItemComboBox1;
        private RepositoryItemImageComboBox repositoryItemImageComboBox1;
        private RepositoryItemLookUpEdit repositoryItemLookUpEdit1;
        private RepositoryItemLookUpEdit repositoryItemLookUpEdit2;
        private RepositoryItemTextEdit repositoryItemTextEdit1;
        private TreeList tlQD;

        public FrmCLQD()
        {
            this.InitializeComponent();
        }

        private void bsCLQD_PositionChanged(object sender, EventArgs e)
        {
        }

        private void btnAddQD_Click(object sender, EventArgs e)
        {
            if (this.tlQD.FocusedNode != null)
            {
                if (this.tlQD.FocusedNode.ParentNode == null)
                {
                    DHelp.DataAddNew(this.bsCLQD, "", "")["bdid"] = this._str1;
                }
                else
                {
                    DHelp.DataAddNewChild(this.bsCLQD, true, this._str1);
                }
            }
            else
            {
                DHelp.DataAddNew(this.bsCLQD, "", "")["bdid"] = this._str1;
            }
        }

        private void btnAddQDChild_Click(object sender, EventArgs e)
        {
            DHelp.DataAddNewChild(this.bsCLQD, false, this._str1);
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            base.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }

        private void btnDelQD_Click(object sender, EventArgs e)
        {
            if (this.tlQD.FocusedNode != null)
            {
                if (!this.tlQD.FocusedNode.HasChildren)
                {
                    DHelp.DelCurRow(this.bsCLQD);
                }
                else
                {
                    MsgBox.ShowMsg("请删除所有子字点后继续此操作");
                }
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            this.bsCLQD.EndEdit();
            if (this.dataSet.HasChanges())
            {
                IDataAccess access = DBHelp.IniIDA();
                access.OpenDatabase();
                access.BeginTrans();
                try
                {
                    access.Update(this.dataSet, true);
                    access.Commit();
                }
                catch (Exception exception)
                {
                    access.RollBack();
                    MsgBox.ShowError("保存数据出错，请与管理员系统！", exception);
                }
                finally
                {
                    access.CloseDatabase();
                }
            }
            this.hasData = this.bsCLQD.List.Count > 0;
            base.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.icontainer != null))
            {
                this.icontainer.Dispose();
            }
            base.Dispose(disposing);
        }

        public void IniData(string xmid, string bdid)
        {
            this._str = xmid;
            this._str1 = bdid;
            this.method1();
            this.dataSet.Tables["CLQD"].TableNewRow += new DataTableNewRowEventHandler(this.method);
        }

        private void InitializeComponent()
        {
            this.icontainer = new Container();
            this.tlQD = new TreeList();
            this.colCLBH = new TreeListColumn();
            this.colCLMC = new TreeListColumn();
            this.colDW = new TreeListColumn();
            this.colDJ = new TreeListColumn();
            this.colSL = new TreeListColumn();
            this.colJE = new TreeListColumn();
            this.colDFBL = new TreeListColumn();
            this.repositoryItemTextEdit1 = new RepositoryItemTextEdit();
            this.colBZ = new TreeListColumn();
            this.bsCLQD = new BindingSource(this.icontainer);
            this.repositoryItemImageComboBox1 = new RepositoryItemImageComboBox();
            this.repositoryItemComboBox1 = new RepositoryItemComboBox();
            this.repositoryItemLookUpEdit1 = new RepositoryItemLookUpEdit();
            this.repositoryItemLookUpEdit2 = new RepositoryItemLookUpEdit();
            this.panelControl5 = new PanelControl();
            this.btnSave = new SimpleButton();
            this.btnClose = new SimpleButton();
            this.btnDelQD = new SimpleButton();
            this.btnAddQDChild = new SimpleButton();
            this.btnAddQD = new SimpleButton();
            this.tlQD.BeginInit();
            this.repositoryItemTextEdit1.BeginInit();
            ((ISupportInitialize) this.bsCLQD).BeginInit();
            this.repositoryItemImageComboBox1.BeginInit();
            this.repositoryItemComboBox1.BeginInit();
            this.repositoryItemLookUpEdit1.BeginInit();
            this.repositoryItemLookUpEdit2.BeginInit();
            this.panelControl5.BeginInit();
            this.panelControl5.SuspendLayout();
            base.SuspendLayout();
            this.tlQD.Columns.AddRange(new TreeListColumn[] { this.colCLMC, this.colCLBH, this.colDW, this.colDJ, this.colSL, this.colJE, this.colDFBL, this.colBZ });
            this.tlQD.DataSource = this.bsCLQD;
            this.tlQD.Dock = DockStyle.Fill;
            this.tlQD.Font = new Font("宋体", 9f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.tlQD.ImageIndexFieldName = "";
            this.tlQD.Location = new Point(0, 0x1b);
            this.tlQD.Name = "tlQD";
            this.tlQD.ParentFieldName = "PID";
            this.tlQD.PreviewFieldName = "CLMC";
            this.tlQD.RepositoryItems.AddRange(new RepositoryItem[] { this.repositoryItemImageComboBox1, this.repositoryItemComboBox1, this.repositoryItemLookUpEdit1, this.repositoryItemLookUpEdit2, this.repositoryItemTextEdit1 });
            this.tlQD.Size = new Size(0x35e, 0x1fb);
            this.tlQD.TabIndex = 7;
            this.tlQD.TreeLineStyle = LineStyle.None;
            this.colCLBH.Caption = "材料编号";
            this.colCLBH.FieldName = "CLBH";
            this.colCLBH.Name = "colCLBH";
            this.colCLBH.Visible = true;
            this.colCLBH.VisibleIndex = 1;
            this.colCLBH.Width = 0x43;
            this.colCLMC.Caption = "材料名称";
            this.colCLMC.FieldName = "CLMC";
            this.colCLMC.Name = "colCLMC";
            this.colCLMC.Visible = true;
            this.colCLMC.VisibleIndex = 0;
            this.colCLMC.Width = 0xa8;
            this.colDW.Caption = "单位";
            this.colDW.FieldName = "DW";
            this.colDW.Name = "colDW";
            this.colDW.Visible = true;
            this.colDW.VisibleIndex = 2;
            this.colDW.Width = 0x56;
            this.colDJ.Caption = "单价";
            this.colDJ.FieldName = "DJ";
            this.colDJ.Name = "colDJ";
            this.colSL.Caption = "数量";
            this.colSL.FieldName = "SL";
            this.colSL.Name = "colSL";
            this.colJE.Caption = "金额";
            this.colJE.FieldName = "JE";
            this.colJE.Name = "colJE";
            this.colDFBL.Caption = "垫付比例 %";
            this.colDFBL.ColumnEdit = this.repositoryItemTextEdit1;
            this.colDFBL.FieldName = "DFBL";
            this.colDFBL.Name = "colDFBL";
            this.colDFBL.Visible = true;
            this.colDFBL.VisibleIndex = 3;
            this.colDFBL.Width = 0x55;
            this.repositoryItemTextEdit1.AutoHeight = false;
            this.repositoryItemTextEdit1.Name = "repositoryItemTextEdit1";
            this.colBZ.Caption = "备注";
            this.colBZ.FieldName = "BZ";
            this.colBZ.Name = "colBZ";
            this.colBZ.Visible = true;
            this.colBZ.VisibleIndex = 4;
            this.colBZ.Width = 0x1b3;
            this.bsCLQD.DataMember = "CLQD";
            this.bsCLQD.PositionChanged += new EventHandler(this.bsCLQD_PositionChanged);
            this.repositoryItemImageComboBox1.AutoHeight = false;
            this.repositoryItemImageComboBox1.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.repositoryItemImageComboBox1.Items.AddRange(new ImageComboBoxItem[] { new ImageComboBoxItem("", "1", 1), new ImageComboBoxItem("", "2", 5), new ImageComboBoxItem("", "3", 11) });
            this.repositoryItemImageComboBox1.Name = "repositoryItemImageComboBox1";
            this.repositoryItemComboBox1.AutoHeight = false;
            this.repositoryItemComboBox1.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.repositoryItemComboBox1.Items.AddRange(new object[] { "普通清单", "计日工", "暂定金" });
            this.repositoryItemComboBox1.Name = "repositoryItemComboBox1";
            this.repositoryItemLookUpEdit1.AutoHeight = false;
            this.repositoryItemLookUpEdit1.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.repositoryItemLookUpEdit1.Name = "repositoryItemLookUpEdit1";
            this.repositoryItemLookUpEdit2.AutoHeight = false;
            this.repositoryItemLookUpEdit2.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.repositoryItemLookUpEdit2.Columns.AddRange(new LookUpColumnInfo[] { new LookUpColumnInfo("code", "code", 20, FormatType.None, "", false, HorzAlignment.Default), new LookUpColumnInfo("value", "value") });
            this.repositoryItemLookUpEdit2.Name = "repositoryItemLookUpEdit2";
            this.panelControl5.Controls.Add(this.btnSave);
            this.panelControl5.Controls.Add(this.btnClose);
            this.panelControl5.Controls.Add(this.btnDelQD);
            this.panelControl5.Controls.Add(this.btnAddQDChild);
            this.panelControl5.Controls.Add(this.btnAddQD);
            this.panelControl5.Dock = DockStyle.Top;
            this.panelControl5.Location = new Point(0, 0);
            this.panelControl5.Name = "panelControl5";
            this.panelControl5.Size = new Size(0x35e, 0x1b);
            this.panelControl5.TabIndex = 6;
            this.btnSave.Dock = DockStyle.Right;
            this.btnSave.Location = new Point(760, 2);
            this.btnSave.Name = "btnSave";
            this.btnSave.Size = new Size(50, 0x17);
            this.btnSave.TabIndex = 4;
            this.btnSave.Text = "保存";
            this.btnSave.Click += new EventHandler(this.btnSave_Click);
            this.btnClose.Dock = DockStyle.Right;
            this.btnClose.Location = new Point(810, 2);
            this.btnClose.Name = "btnClose";
            this.btnClose.Size = new Size(50, 0x17);
            this.btnClose.TabIndex = 3;
            this.btnClose.Text = "关闭";
            this.btnClose.Click += new EventHandler(this.btnClose_Click);
            this.btnDelQD.Dock = DockStyle.Left;
            this.btnDelQD.Location = new Point(0x7a, 2);
            this.btnDelQD.Name = "btnDelQD";
            this.btnDelQD.Size = new Size(50, 0x17);
            this.btnDelQD.TabIndex = 2;
            this.btnDelQD.Text = "删除";
            this.btnDelQD.Click += new EventHandler(this.btnDelQD_Click);
            this.btnAddQDChild.Dock = DockStyle.Left;
            this.btnAddQDChild.Location = new Point(0x3e, 2);
            this.btnAddQDChild.Name = "btnAddQDChild";
            this.btnAddQDChild.Size = new Size(60, 0x17);
            this.btnAddQDChild.TabIndex = 1;
            this.btnAddQDChild.Text = "新增下级";
            this.btnAddQDChild.Click += new EventHandler(this.btnAddQDChild_Click);
            this.btnAddQD.Dock = DockStyle.Left;
            this.btnAddQD.Location = new Point(2, 2);
            this.btnAddQD.Name = "btnAddQD";
            this.btnAddQD.Size = new Size(60, 0x17);
            this.btnAddQD.TabIndex = 0;
            this.btnAddQD.Text = "新增同级";
            this.btnAddQD.Click += new EventHandler(this.btnAddQD_Click);
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            base.ClientSize = new Size(0x35e, 0x216);
            base.Controls.Add(this.tlQD);
            base.Controls.Add(this.panelControl5);
            base.Name = "FrmCLQD";
            base.StartPosition = FormStartPosition.CenterParent;
            this.Text = "材料清单维护";
            base.WindowState = FormWindowState.Maximized;
            this.tlQD.EndInit();
            this.repositoryItemTextEdit1.EndInit();
            ((ISupportInitialize) this.bsCLQD).EndInit();
            this.repositoryItemImageComboBox1.EndInit();
            this.repositoryItemComboBox1.EndInit();
            this.repositoryItemLookUpEdit1.EndInit();
            this.repositoryItemLookUpEdit2.EndInit();
            this.panelControl5.EndInit();
            this.panelControl5.ResumeLayout(false);
            base.ResumeLayout(false);
        }

        private void method(object sender, DataTableNewRowEventArgs e)
        {
            e.Row["id"] = Guid.NewGuid();
            e.Row["xmid"] = this._str;
            e.Row["bdid"] = this._str1;
            e.Row["DFBL"] = this.CLDFBL;
        }

        private void method1()
        {
            this.dataSet.Clear();
            IDataAccess access = DBHelp.IniIDA();
            this.dataSet.Merge(access.ExecuteDataSet("select * from CLQD where bdid='" + this._str1 + "' order by clbh", CommandType.Text, "CLQD"));
            this.bsCLQD.DataSource = this.dataSet.Tables["CLQD"];
            access.CloseDatabase();
        }

        public decimal CLDFBL
        {
            [CompilerGenerated]
            get
            {
                return this._decimal;
            }
            [CompilerGenerated]
            set
            {
                this._decimal = value;
            }
        }
    }
}

